import java.util.Arrays;
import java.util.List;

public class Client {
    public static void main(String[] args) {
        // 创建论文列表
        List<Paper> papers = Arrays.asList(
            new Thesis("基于深度学习的自然语言处理研究"),
            new JournalPaper("人工智能在医疗领域的应用"),
            new ConferencePaper("大数据分析技术"),
            new JournalPaper("云计算与分布式系统"),
            new Thesis("计算机视觉算法研究")
        );

        // 创建选择策略
        PaperSelectionStrategy strategy = new RandomSelectionStrategy();

        // 创建论文列表管理对象
        PaperList paperList = new PaperList("李教授", papers, strategy);

        // 创建学生
        Student student1 = new Student("张三", 2, PaperType.JournalPaper);
        Student student2 = new Student("李四", 1, PaperType.Thesis);
        Student student3 = new Student("王五", 3, PaperType.Any);

        // 学生选择论文
        try {
            List<Paper> selected1 = paperList.selectPapers(student1);
            System.out.println(student1.getName() + " 选择了: " + selected1);

            List<Paper> selected2 = paperList.selectPapers(student2);
            System.out.println(student2.getName() + " 选择了: " + selected2);

            List<Paper> selected3 = paperList.selectPapers(student3);
            System.out.println(student3.getName() + " 选择了: " + selected3);
        } catch (NoEnoughPapersException e) {
            System.out.println(e.getMessage());
        }

        // 使用访问者模式统计已选择论文的学生数量
        PaperSelectionVisitor visitor = new StudentCountVisitor();
        paperList.getSelectionResult().accept(visitor);
        System.out.println("已选择论文的学生数量: " + visitor.getCount());
    }
}    